<template>
	<view class="terminalIncomeMain">
		<view class="terminalIncomeBox">
			<!-- tab -->
			<u-tabs :list="tabList" :is-scroll="false" :current="current" @change="change" bar-height="8"
				active-color="#fb4535"></u-tabs>
			<!-- title -->
			<view class="title">
				<view class="cu-bar">
					<view class="action sub-title top">
						<text class="text-xl text-bold text-orange">{{
              tabList[current].name
            }}</text>
						<text class="bg-orange"></text>
					</view>
				</view>
			</view>
			<!-- data -->
			<!-- 激活返现 -->
			<view class="activeIncomeMain" v-if="current == 0">
				<view class="showPart flex align-center" @tap="goToList">
					<image src="../../static/images/personTrade.png" mode="widthFix" class="topIcon"></image>
					<view class="part">
						<text>个人收益 (元)</text>
						<text>{{
              activeIncome.personalIncome
                ? $tools.format(activeIncome.personalIncome)
                : "0.00"
            }}</text>
					</view>
					<image src="../../static/images/perTradeRed.png" class="partImg"></image>
					<view class="detail">查看详情<u-icon class="uIcon" name="arrow-right" color="#fff" size="24"></u-icon>
					</view>
				</view>
				<view class="showPart flex align-center" @tap="goToList">
					<image src="../../static/images/personTrade2.png" mode="widthFix" class="topIcon"></image>
					<view class="part">
						<text>团队收益 (元)</text>
						<text>{{
              activeIncome.groupIncome
                ? $tools.format(activeIncome.groupIncome)
                : "0.00"
            }}</text>
					</view>
					<image src="../../static/images/perTradeYellow.png" class="partImg"></image>
					<view class="detail">查看详情<u-icon class="uIcon" name="arrow-right" color="#fff" size="24"></u-icon>
					</view>
				</view>
			</view>
			<!-- 达标返现 -->
			<view class="standardIncomeBox" v-if="current == 1">
				<view class="noOpenBox">
					<image src="../../static/images/noData/zwsj.png" mode="widthFix"></image>
					<text>暂未开放</text>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
		<toast></toast>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				tabList: [{
						name: "激活返现",
					},
					{
						name: "达标返现",
					},
				],
				current: 0,
				activeIncome: {
					personalIncome: "0.00",
					groupIncome: "0.00",
				},
			};
		},
		onLoad() {
			this.getIncome2Data();
		},
		onPullDownRefresh() {
			this.getIncome2Data();
		},
		methods: {
			change(index) {
				this.current = index;
			},
			goToList() {
				this.$refs.uToast.show({
					title: "暂未开放",
					type: "error",
					duration: 1200,
				});
			},
			getIncome2Data() {
				this.$u.api
					.getIncome2({
						searchMonth: this.yearMouthDate
					})
					.then((res) => {
						if (res.status == 200) {
							let datas = res.result;
							this.activeIncome = datas;
						}
						uni.stopPullDownRefresh();
					})
					.catch((res) => {
						if (res.errMsg == "request:fail timeout") {
							this.$u.toast("请求超时，请重试!");
						} else if (res.errMsg == "request:fail") {
							this.$u.toast("请求失败，请重试");
						} else {
							this.$u.toast(res.resultDesc);
						}
						this.$loading(false);
						setTimeout(() => {
							this.$u.route({
								type: "navigateBack",
								delta: 1,
							});
						}, 2000);
					});
			},
		},
	};
</script>
<style lang="scss" scoped>
	page {
		background-color: #f9f9f9;
	}

	.title {
		margin: 20rpx 0 0 10rpx;
	}

	.activeIncomeMain {
		padding: 0 30rpx;
		margin-top: 40rpx;

		.showPart {
			position: relative;
			margin-bottom: 60rpx;
			height: 200rpx;
			background-color: #fff;
			border-radius: 14rpx;
			box-shadow: 3rpx 5rpx 8rpx #ccc;

			.part {
				display: flex;
				flex-direction: column;
				margin-left: 80rpx;
				color: #000;
				font-size: 26rpx;
				font-family: numberFont;
				padding-top: 10rpx;

				&>text:last-child {
					padding-top: 10rpx;
					font-size: 40rpx;
					color: #fb4535;
					letter-spacing: 2rpx;
				}
			}

			.topIcon {
				width: 80rpx;
				height: 80rpx;
				position: absolute;
				top: -30rpx;
				left: 40rpx;
			}

			.partImg {
				width: 300rpx;
				height: 180rpx;
				position: absolute;
				top: 9rpx;
				right: 10rpx;
			}

			.detail {
				position: absolute;
				right: 40rpx;
				color: #fff;
				font-weight: 700;
				letter-spacing: 3rpx;
				font-size: 30rpx;
			}
		}
	}

	.noOpenBox {
		padding-top: 60rpx;
		margin-top: 100rpx;
		text-align: center;
		color: #ababab;
		flex-direction: column;

		text {
			display: block;
			margin-top: -10rpx;
			font-size: 36rpx;
			font-weight: bold;
		}

		image {
			width: 220rpx;
			height: 220rpx;
		}
	}
</style>
